package servit;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



import dao.*;
import enily.tbl;
import seriver.tblimpl;

@WebServlet(urlPatterns="/index.shtml")
public class tblservit extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		tbldao mdao = new tblimpl();
	PageBean pageBean = new PageBean(); 
	int condition =mdao.getCount();
		
		pageBean.setTotal(condition);
		String pageStr = req.getParameter("p");
		if(pageStr != null){
			pageBean.setPageNo(Integer.parseInt(pageStr));
		}
		
		List<tbl> list = mdao.getall(pageBean.getPageNo(),pageBean.getSize());
		req.setAttribute("list", list);
		req.setAttribute("pageBean", pageBean);
		
		
		req.getRequestDispatcher("/index.jsp").forward(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(req, resp);
	}

}
